#include "mysqlmodel.h"
#include <QColor>
#include <QFont>

MySqlModel::MySqlModel(QObject * parent, QSqlDatabase db) : QSqlTableModel(parent,db)
{

}

MySqlModel::~MySqlModel()
{

}
void MySqlModel::setQuery(const QSqlQuery &query)
{
    QSqlQueryModel::setQuery(query);
}

QVariant MySqlModel::data(const QModelIndex &idx, int role) const
{
    QVariant value  = QSqlTableModel::data(idx,role);
    if(Qt::TextAlignmentRole == role)
    {
        if(idx.column() <1)
        {
            value   = int(Qt::AlignCenter | Qt::AlignHCenter);
        }
        else
        {
            value   = int(Qt::AlignRight | Qt::AlignHCenter);
        }
        return value;
    }
    /*
    if(Qt::ForegroundRole == role)
    {
        if(3 == idx.column())
            return QVariant(QColor(255,144,144));
    }
    if(Qt::FontRole == role)
    {
        if(3 == idx.column())
        {
            QFont font;
            font.setBold(true);
            return QVariant(font);
        }
    }
    */
    return value;
}
